/*--------------------------------------------------------------------------------------------------
Yatak Operation System Project Copyright 2012-2013
Author : Ilya Churaev
Started : 3 Feb 2013		Updated : 3 Feb 2013
File Name : list_user.c		Purpose : Functions for managment login/logout users
--------------------------------------------------------------------------------------------------*/
#include <yatak/kheap.h>
#include <users.h>
#include <sched.h>

volatile ulist_t * ret_list = NULL;

void save_return_point (task_t * task)
{
	if (!task)
		return;
	if (!ret_list)
	{
		ret_list = (ulist_t *)kmalloc (sizeof(ulist_t));
		ret_list->ret = task;
		ret_list->next = NULL;
		return;
	}
	ulist_t * tmp = (ulist_t *) ret_list;
	while (tmp->next) tmp = tmp->next;
	tmp->next = (ulist_t *)kmalloc (sizeof(ulist_t));
	tmp->next->ret = task;
	tmp->next->next = NULL;
}

task_t * get_return_point ()
{
	if (!ret_list)
		return NULL;
	task_t * task = ret_list->ret;
	ulist_t * tmp = (ulist_t *) ret_list;
	ret_list = ret_list->next;
	kfree ((void *) tmp);
	return task;
}
